package com.liu.yubi.model.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author lqh
* @since 2025-06-03 23:20
 * 图表生成状态枚举类
*/
@Getter
public enum ChartStatusEnum {

    WAIT("等待中","wait"),
    RUNNING("执行中","running"),
    SUCCEED("执行成功","succeed"),
    FAILED("执行失败","failed");

    private final String text;

    private final String value;

     ChartStatusEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    //根据value获取枚举值对象
    public ChartStatusEnum getByValue(String value) {
        if (StringUtils.isBlank (value)){
            return null;
        }
        //便利
        for (ChartStatusEnum chartStatusEnum : values ()) {
            if (value.equals (chartStatusEnum.value)) {
                return chartStatusEnum;
            }
        }
        return null;
    }

    //获取所有value
    public List<String> getValues() {
        return (LinkedList<String>) Arrays.stream (values ()).map (ChartStatusEnum->getValue ()).collect(Collectors.toList());
    }

}
